<?php
/*
 * Created on 2010-9-24
 * @ Author Kevin
 * @ ShangHai
 *
 */
 Yii::import('zii.widgets.CPortlet');
class CollectionList extends CPortlet{
	public $num; //显示收藏排行条数

	public function init(){
		parent::init();
		}

	public function renderContent(){
		$UrBookLib = UrBookLib::model()->with('book')->findAll(array(
			'select'=>'*,count(t.id) as collectcount',
			'group'=>'bid',
			'order'=>'collectcount desc',
			'limit'=>$this->num
		));
	//var_dump($UrBookLib[0]->book);
	$html='';
	$html.="<div class='title'><h2 class='green'>图书馆收藏排行榜</h2></div>";
	$html.="<ul class='collectionlist'>";
	foreach($UrBookLib as $key=>$booklib){
	$no = $key+1;
	if($no<4) $class='red'; else $class='';
	$html.="<li><span class=$class>$no . </span>".l(SiteHelper::YiiSubStr($booklib->book->name,0,13),$booklib->book->url,array('title'=>$booklib->book->name))."</li>";
	}
	$html.="</ul>";
	echo $html;
	}
}
?>
